import React, { Component } from 'react'
import { connect } from 'dva';
import FormList from '../components/ProblemForm';
import {queryProblemInfoById} from '../problemService';

interface Props {
  dispatch: Function,
  match: {
    params: {
      id: number
    }
  }
}

@connect()
class Update extends Component<Props, any> {
  state = {
    detailData: null
  };
  componentWillMount() {
    const { match } = this.props;
    const { params } = match;
    queryProblemInfoById(params.id).then(data => {
      this.setState({
        detailData: data
      })
    });
  }
  render() {
    return (
      <>
        <FormList data={this.state.detailData} key={Date.now()}/>
      </>
    );
  }
}

export default Update;
